﻿/// <reference path="jquery-1.6.2.js" />

ui = {};

var BLANK_IMG_URL = '../images/blank.gif';

ui.checkbox = function (boxes) {
    /// <param name="boxes" type="jQuery" />
    this.boxes = $(boxes);
}

ui.checkbox.prototype.replace = function () {
    this.boxes.each(function (i, b) {
        b = $(b).hide().after('<img src="' + BLANK_IMG_URL + '" class="checkbox"/>');
        b.change(function () { b.next()[this.checked ? 'addClass' : 'removeClass']('checked') }).change();
    });
}

ui.select = function (selects) {
    /// <param name="selects" type="jQuery" />
    this.selects = $(selects);
}
ui.select.prototype.replace = function () {
    this.selects.each(function (i, s) {
        var select = $('<div class="select"/>').insertAfter(s = $(s).hide()),
            label = $('<label></label>').appendTo(select),
            div = $('<div class="hide"></div>').appendTo(select);

        select.mouseenter(function () { select.addClass('hover') })
              .mouseleave(function () { select.removeClass('hover') });

        $.each(s[0].options, function (i, o) {
            $('<a href="javascript://;">' + o.text + '</a>').appendTo(div).click(function (e) {
                s[0].selectedIndex = i;
                select.mouseleave();
                s.change();
            });
        });
        s.change(function (e) {
            label.text(this.options[this.selectedIndex].text);
        }).change();
    });
}

dialog = {};

dialog.alert = function (msg) {

}